package com.noah.common.trace.interceptor;

import com.noah.common.constant.BizConstant;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * @author noah
 * 2023/9/13 19:22
 */
public class TraceInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        String traceId=request.getHeader(BizConstant.TRACE_ID);
        String userId=request.getHeader(BizConstant.USER_ID);
        String userName=request.getHeader(BizConstant.USER_NAME);
        String tenantId=request.getHeader(BizConstant.TENANT_ID);

        // 进行trace 拦截配置
        return true;
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        // 进行后续处理
    }
}
